package com.yuanfeng.job.mapper;

import com.yuanfeng.commoms.dto.order.AddInventoryDTO;
import com.yuanfeng.commoms.dto.order.CancelParaEntityDTO;
import com.yuanfeng.commoms.dto.order.WapGoodsSaleSumDTO;
import com.yuanfeng.commoms.vo.goods.WapGoodsSaleSumUpdateVO;
import com.yuanfeng.job.dto.AppJiPushOrderDTO;
import com.yuanfeng.job.dto.BusinessOvertimeOrderDTO;
import com.yuanfeng.job.dto.OrderStatusDTO;
import com.yuanfeng.job.dto.RefundParamTwoDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * @ClassName UpdateOrderStatusMapper
 * @Description 订单状态
 * @Author liulh
 * @Date 2023/5/17 17:12
 * @Version 1.0
 **/
@Mapper
public interface UpdateOrderStatusMapper{

    /**
     * 获取待更新状态订单信息
     * @return
     */
    List<AppJiPushOrderDTO> listForUpdateOrder();

    /**
     * 更新所有超时未确认收货订单相关记录
     * @param orderId
     * @return
     */
    Integer updateForUpdateOrder(String orderId);

    /**
     * 更新所有待超时订单
     * @param orderId
     * @return
     */
    Integer updateForUpdateGoods(String orderId);

    /**
     * 查询超过n分钟额订单
     * @param minutes
     * @return
     */
    List<String> listTimeoutOrder2(@Param("minutes") String minutes);

    /**
     * 根据订单Id查询 商品 数量 Id
     * @param orderId
     * @return
     */
    List<WapGoodsSaleSumDTO> queryGoodsXinXi(String orderId);

    /**
     * 查询商品销量
     * @param goodsId
     * @return
     */
    Map<String, Long> queryGoodsCommonStock(@Param("goodsId") Integer goodsId);

    /**
     * 更新商品库存
     * @param param
     * @return
     */
    Integer updateCommonStockByGoodsId(WapGoodsSaleSumDTO param);

    /**
     * 更新商品库存
     * @param param
     * @return
     */
    Integer updateGoodsStockByGoodsId(WapGoodsSaleSumDTO param);


    /**
     * 返回红包
     * @param minutes
     * @return
     */
    List<OrderStatusDTO> listTimeoutOrderDetail2(@Param("minutes") String minutes);

    /**
     * 查询订单状态及退货退款状态
     * @param paymentNumber
     * @return
     */
    List<Integer> queryOrderStatus(@Param("paymentNumber") String paymentNumber);

    /**
     * 更新超过24小时未支付订单
     * @param minutes
     * @return
     */
    Integer updateTimeoutOrder2(@Param("minutes") String minutes);

    /**
     * 更新所有超时未支付订单
     * @param orderId
     * @return
     */
    Integer updateTimeoutOrderGoods(String orderId);

    /**
     * 更新所有超时未支付订单关联的审批
     * @param orderId
     * @return
     */
    Integer editApprovalId(String orderId);

    /**
     * 查询超出48小时商家未处理售后退款订单
     * @return
     */
    List<BusinessOvertimeOrderDTO> queryReturnOrderNotHandle();

    /**
     * 查询超出24小时退款商家未同意订单
     *
     * @return
     */
    List<BusinessOvertimeOrderDTO> queryBusinessOvertimeOrder();

    /**
     * 查询支付数量
     *
     * @param param
     * @return
     */
    String queryPaymentNumber(BusinessOvertimeOrderDTO param);


    /**
     * 查询退款所需参数
     * @param orderId
     * @return
     */
    RefundParamTwoDTO queryRefundPara(@Param("orderId") String orderId);


    /**
     * 更新订单表状态
     * @param param
     * @return
     */
    Integer updateBusinessOvertimeOrderBase(BusinessOvertimeOrderDTO param);


    /**
     * 更新退款
    /**
     * 更新返回订单
     *
     * @param param
     * @return
     */
    Integer updateBusinessOvertimeOrderReturn(BusinessOvertimeOrderDTO param);

    /**
     * 查询超过48小时商家未处理的订单
     * @return
     */
    List<BusinessOvertimeOrderDTO> queryTuiHuoOrderNotHandle();

    /**
     *更新退款信息
     * @param orderGoodsMap
     * @return
     */
    Integer updateOrderReturnById(@Param("param") Map<String, Object> orderGoodsMap);


    /**
     * 根据付单号查退款状态
     * @param uOrderId
     * @return
     */
    List<Integer> queryOrderRecordStatus(@Param("uOrderId") String uOrderId);


    List<String> queryUnpaidOrdersToBeCancelled();

    List<AddInventoryDTO> queryGoodsDetails(@Param("orderId")String orderId);

    void updateSaleSum2(@Param("param") WapGoodsSaleSumUpdateVO wgssu);

    boolean updateByOrderBase(@Param("orderId")String orderId,@Param("orderStatus") Integer orderStatus, @Param("orderCancelIdentity")Integer orderCancelIdentity,@Param("orderCancelReason") String orderCancelReason,@Param("orderCancelDate") String orderCancelDate);

    boolean updateByOrderGoods(@Param("orderId")String orderId, @Param("orderStatus")Integer orderStatus);

    void updateOrderStatus(@Param("orderStatus")Integer status, @Param("orderId") String orderId);

    CancelParaEntityDTO queryPaymentNumberAndRedpacketId(@Param("orderId") String orderId);
}
